<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>模型 model 列表</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script src="/layui/layui.all.js"></script>
</head>
<body>
<table class="layui-table">
    <thead>
    <tr>
        <#--        <th>模型图</th>-->
        <th>模型名称</th>
        <th>模型ID</th>
        <th>流程Key</th>
        <th>版本</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <#list modelList! as model>
        <tr>
            <#--            <td>-->
            <#--                <button class="layui-btn layui-btn-primary" onclick="showImage('${ process.id!"" }')">显示流程图</button>-->
            <#--            </td>-->
            <td>${ model.name!"" }</td>
            <td>${ model.id!"" }</td>
            <td>${ model.key!"" }</td>
            <td>${ model.version!"" }</td>
            <td>
                <button onclick="deployModel('${model.id!}')" class="layui-btn">部署</button>
            </td>
        </tr>
    </#list>
    </tbody>
</table>

<img id="processImage" width="50%">

<script>
    var $ = layui.$;

    /**
     * 显示流程图
     * @param deploymentId
     */
    function showImage(processDefinitionId) {
        $.get({
            url: "/process/image/" + processDefinitionId
            , success: function (res) {
                $("#processImage").attr("src", res);
            }
        });
    }

    /**
     * 部署模型
     * @param modelId
     */
    function deployModel(modelId) {
        $.get({
            url: "/deploy/model/" + modelId
            , success: function (res) {
                layui.layer.msg(res);
            }
        });
    }
</script>
</body>
</html>